﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Physis.Client.JsonResponses {

    public class ResponseBase {

        #region Private Properties

        private String exceptionMessage = String.Empty;

        private String informationMessage = String.Empty;

        private String responseScript = String.Empty;

        #endregion


        #region Public Properties

        /// <summary>Boolean indicator for if there was an Exception while processing that is captured in the Model.</summary>
        public Boolean HasException { get { return !(String.IsNullOrWhiteSpace (exceptionMessage)); } }

        /// <summary>Last Exception Message</summary>
        public String ExceptionMessage { get { return exceptionMessage; } }

        /// <summary>Boolean indicator for if there is an information message available from processing.</summary>
        public Boolean HasInformationMessage { get { return !(String.IsNullOrWhiteSpace (informationMessage)); } }

        /// <summary>Informational Message</summary>
        public String InformationMessage { get { return informationMessage; } set { informationMessage = value; } }

        /// <summary>Javascript to Execute after a AJAX request is completed.</summary>
        public String ResponseScript { get { return responseScript; } set { responseScript = value; } }

        #endregion


        #region Public Methods

        public virtual void SetException (Exception exception) {

            if (exception != null) { exceptionMessage = exception.Message; }

            else { exceptionMessage = String.Empty; }

            return;

        }

        public virtual void SetException (String forExceptionMessage) {

            exceptionMessage = forExceptionMessage;

            return;

        }

        #endregion

    }

}